package com.mall.config;


import com.mall.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Component
@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/pro-mall/files/**")
                .addResourceLocations("file:E:/word/MobileFile/mall-pro/src/main/resources/static/pro-mall/files/");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                .excludePathPatterns("pro-mall/font-awesome-4.7.0/**")
                .excludePathPatterns("/pro-mall/**/**.js")
                .excludePathPatterns("/pro-mall/**/**.css")
                .excludePathPatterns("/pro-mall/pages/login.html")
                .excludePathPatterns("/pro-mall/pages/regeist.html")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/user/regeist")
                .excludePathPatterns("/pro-mall/vues/login.vue")
                .excludePathPatterns("/pro-mall/vues/regeist.vue")
                .excludePathPatterns("/pro-mall/imgs/**");

    }
}
